package Java;

import java.util.Scanner;

//        5、打印菱形，用户输入菱形边长，用*打印出空心菱形。
public class test16 {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    System.out.print("请输入菱形边长：");
    int total = scanner.nextInt();
    int sum=total;
    for (int i = 1; i < sum+1; i++) {
      for (int k = 1; k <= sum+1 - i; k++) {
        System.out.print(" ");
      }
      for (int j = 1; j <= 2 * i - 1; j++) {
        if (j == 1 || j == 2 * i - 1) {
          System.out.print("*");
        } else {
          System.out.print(" ");
        }
      }
      System.out.println("");
    }
    for (int i=0;i<=sum;i++){
      for (int k=0;k<=i;k++){
        System.out.print(" ");
      }
      for (int j=sum-2-i;j>=0;j--){
        if (j==0||j==sum-2-i){
          System.out.print(" *");
        }else {
          System.out.print("  ");
        }
      }
      System.out.println("");
    }

























/*   Scanner scanner=new Scanner(System.in);
    int x=scanner.nextInt();
    printHollowRhombus(x);
      }
      public static void printHollowRhombus(int size) {
        if (size % 2 == 0) {
          size++;// 计算菱形大小
        }
        for (int i = 0; i < size / 2 + 1; i++) {
          for (int j = size / 2 + 1; j > i + 1; j--) {
            System.out.print("  ");// 输出左上角位置的空白
          }
          for (int j = 0; j < 2 * i + 1; j++) {
            if (j == 0 || j == 2 * i) {
              System.out.print("* ");// 输出菱形上半部边缘
            } else {
              System.out.print("  ");// 输出菱形上半部空心
            }
          }
          System.out.println("");     //换行
        }
        for (int i = size / 2 + 1; i < size; i++) {
          for (int j = 0; j < i - size / 2; j++) {
            System.out.print("  ");// 输出菱形左下角空白
          }
          for (int j = 0; j < 2 * size - 1 - 2 * i; j++) {
            if (j == 0 || j == 2 * (size - i - 1)) {
              System.out.print("* ");// 输出菱形下半部边缘
            } else {
              System.out.print("  ");// 输出菱形下半部空心
            }
          }
          System.out.println("");     //换行
        }
  }*/
    }
}

